/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package foxmob.mlts.viewcontroller.setter;

import foxmob.mlts.controller.setter.SectionFormController;
import foxmob.mlts.controller.setter.SetterFormController;
import javax.swing.JButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;

/**
 *
 * @author Lunayo
 */
public class SectionForm extends RootModifyForm {

    /**
     * Creates new form SectionForm
     */
    public SectionForm() {
        initComponents();
    }
    
    public SectionForm(SetterFormController delegate) {
        initComponents();
        sectionFormController = new SectionFormController(delegate, this);
    }
    
    public SectionFormController getSectionFormController() {
        return sectionFormController;
    }
    
    public JTextArea getDescriptionText() {
        return this.descriptionText;
    }
    
    public JTextField getTimeText() {
        return this.timeText;
    }
    
    public JTextField getSectionText() {
        return this.sectionText;
    }
    
    public JButton getSaveButton() {
        return this.saveButton;
    }
    
    public JButton getAddSubsectionButton() {
        return this.addSubsectionButton;
    }
    
    public JButton getDeleteSectionButton() {
        return this.deleteSectionButton;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPasswordField1 = new javax.swing.JPasswordField();
        sectionPanel = new javax.swing.JPanel();
        sectionLabel = new javax.swing.JLabel();
        sectionText = new javax.swing.JTextField();
        saveButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        descriptionText = new javax.swing.JTextArea();
        descriptionLabel = new javax.swing.JLabel();
        timeLabel = new javax.swing.JLabel();
        timeText = new javax.swing.JTextField();
        deleteSectionButton = new javax.swing.JButton();
        addSubsectionButton = new javax.swing.JButton();

        jPasswordField1.setText("jPasswordField1");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        sectionPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Section"));

        sectionLabel.setText("Section :");

        saveButton.setText("Add Section");
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });

        descriptionText.setColumns(20);
        descriptionText.setRows(5);
        jScrollPane1.setViewportView(descriptionText);

        descriptionLabel.setText("Description :");

        timeLabel.setText("Time (S) :");

        deleteSectionButton.setText("Delete Section");
        deleteSectionButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteSectionButtonActionPerformed(evt);
            }
        });

        addSubsectionButton.setText("Add Subsection");
        addSubsectionButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addSubsectionButtonActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout sectionPanelLayout = new org.jdesktop.layout.GroupLayout(sectionPanel);
        sectionPanel.setLayout(sectionPanelLayout);
        sectionPanelLayout.setHorizontalGroup(
            sectionPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(sectionPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(sectionPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(sectionPanelLayout.createSequentialGroup()
                        .add(sectionPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(sectionPanelLayout.createSequentialGroup()
                                .add(1, 1, 1)
                                .add(sectionLabel))
                            .add(descriptionLabel)
                            .add(timeLabel))
                        .add(18, 18, Short.MAX_VALUE)
                        .add(sectionPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, timeText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 51, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, sectionText)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 381, Short.MAX_VALUE)))
                    .add(sectionPanelLayout.createSequentialGroup()
                        .add(0, 67, Short.MAX_VALUE)
                        .add(addSubsectionButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(deleteSectionButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(saveButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 135, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        sectionPanelLayout.setVerticalGroup(
            sectionPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(sectionPanelLayout.createSequentialGroup()
                .add(sectionPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(sectionLabel)
                    .add(sectionText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(sectionPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(descriptionLabel)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(sectionPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(timeLabel)
                    .add(timeText, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(12, 12, 12)
                .add(sectionPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(saveButton)
                    .add(deleteSectionButton)
                    .add(addSubsectionButton)))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(sectionPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(sectionPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        // TODO add your handling code here:
        sectionFormController.saveButtonDidTap();
    }//GEN-LAST:event_saveButtonActionPerformed

    private void addSubsectionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addSubsectionButtonActionPerformed
        // TODO add your handling code here:
        sectionFormController.addSubsectionButtonDidTap();
    }//GEN-LAST:event_addSubsectionButtonActionPerformed

    private void deleteSectionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteSectionButtonActionPerformed
        // TODO add your handling code here:
        sectionFormController.deleteSubsectionButtonDidTap();
    }//GEN-LAST:event_deleteSectionButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(SectionForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(SectionForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(SectionForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(SectionForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new SectionForm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addSubsectionButton;
    private javax.swing.JButton deleteSectionButton;
    private javax.swing.JLabel descriptionLabel;
    private javax.swing.JTextArea descriptionText;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton saveButton;
    private javax.swing.JLabel sectionLabel;
    private javax.swing.JPanel sectionPanel;
    private javax.swing.JTextField sectionText;
    private javax.swing.JLabel timeLabel;
    private javax.swing.JTextField timeText;
    // End of variables declaration//GEN-END:variables

    private SectionFormController sectionFormController;
}
